<template>
  <div>
    <el-button @click="openMap" type="primary">open地图</el-button>
    <GdMapChoose ref="gdmap"></GdMapChoose>
    <BdMapChoose ref="bdmap"></BdMapChoose>
    <TxMapChoose ref="txmap"></TxMapChoose>
  </div>
</template>

<script>
import BdMapChoose from './BdMapChoose.vue'
import GdMapChoose from './GdMapChoose.vue'
import TxMapChoose from './TxMapChoose.vue'
import * as mapUtils from '@/utils/gdMap.js'
import * as txApi from '@/utils/txApi.js'

export default {
  components: {
    BdMapChoose,
    GdMapChoose,
    TxMapChoose
  },
  methods: {
    async openMap() {
      // const location = await txApi.location()
      // console.log(location);
      // const { lat, lng } = location.data.result.location

      // const geocoderLocation = await txApi.geocoderLocation(lat + ',' + lng)
      // console.log(geocoderLocation);
      this.$refs.bdmap.modelIsOpen = true
      return
      try {
        const res = await mapUtils.checkGdLocation()
        console.log('高德', res)
        this.$refs.gdmap.modelIsOpen = true
      } catch (error) {
        console.log('百度', error)
        this.$refs.bdmap.modelIsOpen = true
      }
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
